package com.snail.controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@RestController
@RequestMapping("/api/order")
public class OrderController {



    /**
     * 创建订单
     * @param productId 商品ID
     * @param productName 商品名称
     * @param amount 金额
     * @return 订单信息
     */
    @PostMapping("/create")
    public Map<String, Object> createOrder(@RequestParam Long productId,
                                           @RequestParam String productName,
                                           @RequestParam Double amount) {
        Map<String, Object> result = new HashMap<>();

        // 生成订单号 (实际项目中应该从数据库生成)
        String orderNo = UUID.randomUUID().toString().replace("-", "");

        result.put("orderNo", orderNo);
        result.put("productId", productId);
        result.put("productName", productName);
        result.put("amount", amount);

        return result;
    }
}